<%inherit file="/base/user.html"/>

<p>
%if c.user_slcs_dn and c.user_client_dn:
    From the AAI credentials (SCLS certificate) and the certificate, which 
    was presented by your browser, you may be allowed to submit 
    jobs on below listed clusters.
%elif c.user_slcs_dn:
    From the AAI credentials (SCLS certificate), you may be allowed to submit 
    jobs on below listed clusters.
%elif c.user_client_dn:
    From the browser certificate, which was presented by your browser, you 
    may be allowd to submit jobs on the clusters listed in below table.
%else:
    Dear ${c.user_name}, from the crendentials by which you accessed this site, there are no 
    clusters you may be allowed to run jobs on. 
% endif

</p>

% if c.user_slcs_dn or c.user_client_dn:
    <table id="grid_pub_summary" cellspacing="0" summary="An summary of the 
            Grid computational resources the ${c.user_name} ${c.user_surname} user may be
            allowed to access">
                <caption>
                    ${config['gridname']} Resources Overview for ${c.user_name} ${c.user_surname}.
                </caption>
                <tr>
                    <th class="gm corner_left" scope="col">Cluster</th>
                    <th class="gm" scope="col">Status</th>
                    <th class="gm" scope="col">CPU Load</th>
                    <th class="gm" scope="col">Queue Load</th>
                    <th class="gm" scope="col">Load Table 
                     <span id="expand_table"> 
                        |&lt;- -&gt;|  
                     </span>
                     <span id="shrink_table" style="display: none">  
                        |-&gt;&lt;-| 
                    </span>
                    </th>
                    <th class="gm corner_right" scope="col">RRD</th>
                </tr>
                <% zebra_cnt = 0 %>

    % for hostname in c.user_clusters:
    <% 
    zebra_cnt += 1 
    if c.clusters_meta.has_key(hostname) and c.clusters_meta[hostname].has_key('alias'):
        display_name = c.clusters_meta[hostname]['alias']
    else:
        display_name = hostname
    id_tag = hostname.replace('.','-1-')
    %>
                    % if zebra_cnt % 2 == 0:
                        <tr class="odd" id="${id_tag}">
                        
                    % else:
                        <tr class="even" id="${id_tag}">
                    % endif
                        <!-- static cluster information -->
                        <td class='emph' display_name='${display_name}'>
                            <div class='cluster_details'>
                                <h2> ${display_name}</h2>
                                <table summary="Cluster details infobox">
                                    <tr><td>Hostname</td> <td>${hostname}</td> </tr>
                                    %if c.clusters_meta.has_key(hostname):
                                        % for k, v in c.clusters_meta[hostname].items():
                                            % if k != 'alias':
                                                <tr>
                                                    <td> ${k} </td>
                                                    <td> ${v} </td>
                                                </tr>
                                            %endif
                                        % endfor
                                    %else:
                                        <tr><td colspan=2 > <span class="warn_status">No up-to-date info available </span> </td> </tr>
                                    %endif
                                </table>
                            </div>
                        </td>
                        <!-- 2nd: status row (dynamic)-->
                        <td>
                            <div class="undef_status" status="Downtime" style="display: none;"> Downtime</div>
                            <div group='nsi'>
                                <div class="undef_status" status="Nagios"></div>
                                <div class="undef_status" status="SFT"></div> 
                                <div class="undef_status" status="Infosys"></div>
                            </div>
                        </td>
                    <!-- 3rd CPU load -->
                    <td class="plot"><div id= "${id_tag + '_cpu'}"></div></td>
                    <!-- 4th Queue load -->
                    <td class="plot"><div id= "${id_tag + '_queue'}"></div></td>
                    <!-- 5th CPU Queue load table -->
                    <td id="${id_tag + '_table'}"> 
                    </td>
                    <td><a href="/public/rrd/${hostname}" target="_blank"><img src="/img/graph_thumb.png"
                    alt="rrd graph;logo from royalty free clip art site clker.com"/></a></td>
                    </tr>
                % endfor 
                
            </table>
    <script type="text/javascript" src="/js/cluster_status.js"> </script>
    <script type="text/javascript" src="/js/qtip/cluster_details.js">// Create the tooltips only on document load</script>

    <%def name="css()">
        ${parent.css()}
        ${self.css_link('/css/tooltip.css', 'screen')}
    </%def>

    <%def name="js()">        
        ${parent.js()}
        ${self.js_link("/js/qtip/jquery.qtip-1.0.0-rc3.min.js")}
        ${self.js_link("https://www.google.com/jsapi")}
        ${self.js_link("/js/cluster_load.js")}
    </%def>
%endif
